<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Navo Portable Library: navo/algorithm/linear/sequence/dlseq.h源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- 制作者 Doxygen 1.7.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'搜索');
--></script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Navo Portable Library&#160;<span id="projectnumber">Ver 1.0.20120827</span></div>
   <div id="projectbrief">Provides generic platform independent facilities.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="modules.html"><span>模块</span></a></li>
      <li><a href="annotated.html"><span>数据结构</span></a></li>
      <li class="current"><a href="files.html"><span>文件</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="搜索" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>文件列表</span></a></li>
      <li><a href="globals.html"><span>全局定义</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<h1>navo/algorithm/linear/sequence/dlseq.h</h1>  </div>
</div>
<div class="contents">
<a href="dlseq_8h.html">浏览该文件的文档。</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */</span>
<a name="l00011"></a>00011 <span class="preprocessor">#ifdef _MSC_VER</span>
<a name="l00012"></a>00012 <span class="preprocessor"></span><span class="preprocessor">#pragma once</span>
<a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* #ifdef _MSC_VER */</span>
<a name="l00014"></a>00014 
<a name="l00015"></a>00015 <span class="preprocessor">#ifndef __NV_DLSEQ__</span>
<a name="l00016"></a>00016 <span class="preprocessor"></span><span class="preprocessor">#define __NV_DLSEQ__</span>
<a name="l00017"></a>00017 <span class="preprocessor"></span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &quot;<a class="code" href="cdef_8h.html" title="Definitions and declarations for common constants, types, variables.">../../../port/cdef.h</a>&quot;</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#include &lt;cstring&gt;</span>
<a name="l00022"></a>00022 <span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {
<a name="l00023"></a>00023 <span class="preprocessor">#else</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#endif </span><span class="comment">/* #ifdef __cplusplus */</span>
<a name="l00026"></a>00026 
<a name="l00038"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gaa9af64320d2e9425bd7bdd61b1911dda">00038</a> <span class="preprocessor">#define dlseq_iter(type) type *</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span>
<a name="l00051"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga3437c799d3e0d406d09c5ca77229df31">00051</a> <span class="preprocessor">#define dlseq_head(type) \</span>
<a name="l00052"></a>00052 <span class="preprocessor">    struct { type * first; type * last; type * end; type * base; }</span>
<a name="l00053"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gae82111648a741688ce3924aafdd5494f">00053</a> <span class="preprocessor"></span><span class="preprocessor">#define dlseq dlseq_head</span>
<a name="l00054"></a>00054 <span class="preprocessor"></span>
<a name="l00065"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gaa216302ea43c71dc4805b478885559f4">00065</a> <span class="preprocessor">#define DLSEQ_HEAD(type, name, arr) \</span>
<a name="l00066"></a>00066 <span class="preprocessor">    dlseq_head(type) name = {arr, arr, &amp;arr[count_of(arr)], arr}</span>
<a name="l00067"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gac7d0810e0d8768918cba80c88652a262">00067</a> <span class="preprocessor"></span><span class="preprocessor">#define DLSEQ DLSEQ_HEAD</span>
<a name="l00068"></a>00068 <span class="preprocessor"></span>
<a name="l00077"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gaf69ab959476f5ca5a5ed257f00403cea">00077</a> <span class="preprocessor">#define dlseq_pr1(type) int (*)(type *)</span>
<a name="l00078"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gae8922449d1b0a688414b4e9ce517e152">00078</a> <span class="preprocessor"></span><span class="preprocessor">#define dlseq_pr2(type) int (*)(type *, type *)</span>
<a name="l00079"></a>00079 <span class="preprocessor"></span>
<a name="l00080"></a>00080 <span class="preprocessor">#define DLSEQ_CHECK_PASS        0 </span><span class="comment">/* 正常 */</span>
<a name="l00081"></a>00081 <span class="preprocessor">#define DLSEQ_CHECK_INVALID     1 </span><span class="comment">/* 无效缓存 */</span>
<a name="l00082"></a>00082 <span class="preprocessor">#define DLSEQ_CHECK_OVERFLOW    2 </span><span class="comment">/* 溢出 */</span>
<a name="l00083"></a>00083 
<a name="l00084"></a>00084 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> __dlseq_check(<span class="keywordtype">char</span>* first, <span class="keywordtype">char</span>* last,
<a name="l00085"></a>00085                                 <span class="keywordtype">char</span>* end, <span class="keywordtype">char</span>* base)
<a name="l00086"></a>00086 {
<a name="l00087"></a>00087     <span class="keywordflow">if</span> (!base || base &gt;= end || first &gt;= end)
<a name="l00088"></a>00088         <span class="keywordflow">return</span> DLSEQ_CHECK_INVALID;
<a name="l00089"></a>00089     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (last &gt; end || first &lt; base)
<a name="l00090"></a>00090         <span class="keywordflow">return</span> DLSEQ_CHECK_OVERFLOW;
<a name="l00091"></a>00091     <span class="keywordflow">else</span>
<a name="l00092"></a>00092         <span class="keywordflow">return</span> DLSEQ_CHECK_PASS;
<a name="l00093"></a>00093 }
<a name="l00094"></a>00094 
<a name="l00104"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga445d19b93a297685508fa4c4440e633e">00104</a> <span class="preprocessor">#define dlseq_check(head) \</span>
<a name="l00105"></a>00105 <span class="preprocessor">    __dlseq_check((char*)((head)-&gt;first),   \</span>
<a name="l00106"></a>00106 <span class="preprocessor">                  (char*)((head)-&gt;last),    \</span>
<a name="l00107"></a>00107 <span class="preprocessor">                  (char*)((head)-&gt;end),     \</span>
<a name="l00108"></a>00108 <span class="preprocessor">                  (char*)((head)-&gt;base))</span>
<a name="l00109"></a>00109 <span class="preprocessor"></span>
<a name="l00119"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga76d23d6cbe36669ffdd7319e48ca6f14">00119</a> <span class="preprocessor">#define dlseq_reset(head, _base, _first, _last, _end) \</span>
<a name="l00120"></a>00120 <span class="preprocessor">    do {(head)-&gt;base = (_base);         \</span>
<a name="l00121"></a>00121 <span class="preprocessor">        (head)-&gt;first = (_first);       \</span>
<a name="l00122"></a>00122 <span class="preprocessor">        (head)-&gt;last = (_last);         \</span>
<a name="l00123"></a>00123 <span class="preprocessor">        (head)-&gt;end = (_end);           \</span>
<a name="l00124"></a>00124 <span class="preprocessor">    } while (0)</span>
<a name="l00125"></a>00125 <span class="preprocessor"></span>
<a name="l00136"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga3cc1579b04bc1c6992a481f176a1feab">00136</a> <span class="preprocessor">#define dlseq_init(type, head, base, size, _first)  \</span>
<a name="l00137"></a>00137 <span class="preprocessor">    dlseq_reset(head, (type *)(base),               \</span>
<a name="l00138"></a>00138 <span class="preprocessor">                (type *)(base) + (_first),          \</span>
<a name="l00139"></a>00139 <span class="preprocessor">                (type *)(base) + (_first),          \</span>
<a name="l00140"></a>00140 <span class="preprocessor">                (type *)(base) + (size))            \</span>
<a name="l00141"></a>00141 <span class="preprocessor"></span>
<a name="l00142"></a>00142 <span class="preprocessor"></span>
<a name="l00171"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gabf5ed6c58292209957b42e4d48c2d1a1">00171</a> <span class="preprocessor">#define dlseq_init_serial(type, head, base, size, cnt)  \</span>
<a name="l00172"></a>00172 <span class="preprocessor">    dlseq_reset(head, (type *)(base), (type *)(base),   \</span>
<a name="l00173"></a>00173 <span class="preprocessor">                (type *)(base) + (cnt),                 \</span>
<a name="l00174"></a>00174 <span class="preprocessor">                (type *)(base) + (size))</span>
<a name="l00175"></a>00175 <span class="preprocessor"></span>
<a name="l00207"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga889a2f601d1d09072124ef08ddc584e6">00207</a> <span class="preprocessor">#define DLSEQ_INIT(type, head, arr, _first) \</span>
<a name="l00208"></a>00208 <span class="preprocessor">    dlseq_init(type, head, arr, count_of(arr), _first)</span>
<a name="l00209"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gab10a512399502928d8663659815ebaea">00209</a> <span class="preprocessor"></span><span class="preprocessor">#define DLSEQ_INIT_SERIAL(type, head, arr, cnt) \</span>
<a name="l00210"></a>00210 <span class="preprocessor">    dlseq_init_serial(type, head, arr, count_of(arr), cnt)</span>
<a name="l00211"></a>00211 <span class="preprocessor"></span>
<a name="l00217"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gac0cde607f5cd2c7c915763b5bf554036">00217</a> <span class="preprocessor">#define dlseq_clear(head) \</span>
<a name="l00218"></a>00218 <span class="preprocessor">    ((head)-&gt;last = (head)-&gt;first = (head)-&gt;base)</span>
<a name="l00219"></a>00219 <span class="preprocessor"></span>
<a name="l00226"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga484f9e8336a526af76143a85170165a7">00226</a> <span class="preprocessor">#define dlseq_base(head) ((head)-&gt;base)</span>
<a name="l00227"></a>00227 <span class="preprocessor"></span>
<a name="l00234"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga0fcd66f91e5863d48fb4730721655885">00234</a> <span class="preprocessor">#define dlseq_count(head) \</span>
<a name="l00235"></a>00235 <span class="preprocessor">    ((size_t)((head)-&gt;last - (head)-&gt;first))</span>
<a name="l00236"></a>00236 <span class="preprocessor"></span>
<a name="l00244"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga2be894336225299ffb21b4c3e79213ac">00244</a> <span class="preprocessor">#define dlseq_size(head) \</span>
<a name="l00245"></a>00245 <span class="preprocessor">    ((size_t)((head)-&gt;end - (head)-&gt;base))</span>
<a name="l00246"></a>00246 <span class="preprocessor"></span>
<a name="l00254"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga68218badfdc550c54b6b6911cc67ff2e">00254</a> <span class="preprocessor">#define dlseq_capacity(head) dlseq_size(head)</span>
<a name="l00255"></a>00255 <span class="preprocessor"></span>
<a name="l00263"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga093081eb99a26f23856a62408d5b1afd">00263</a> <span class="preprocessor">#define dlseq_remain(head) \</span>
<a name="l00264"></a>00264 <span class="preprocessor">    (dlseq_size(head) - dlseq_count(head))</span>
<a name="l00265"></a>00265 <span class="preprocessor"></span>
<a name="l00273"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gaa98669095b34719d99d6ea02df035866">00273</a> <span class="preprocessor">#define dlseq_front_remain(head) \</span>
<a name="l00274"></a>00274 <span class="preprocessor">    ((size_t)((head)-&gt;first - (head)-&gt;base))</span>
<a name="l00275"></a>00275 <span class="preprocessor"></span>
<a name="l00283"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga3c099faa672dbfa60c279736e5c99468">00283</a> <span class="preprocessor">#define dlseq_back_remain(head) \</span>
<a name="l00284"></a>00284 <span class="preprocessor">    ((size_t)((head)-&gt;end - (head)-&gt;last))</span>
<a name="l00285"></a>00285 <span class="preprocessor"></span>
<a name="l00295"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga3ff49337827821b5c85223648b9cdb5d">00295</a> <span class="preprocessor">#define dlseq_empty(head) ((head)-&gt;first &gt;= (head)-&gt;last)</span>
<a name="l00296"></a>00296 <span class="preprocessor"></span>
<a name="l00306"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga7a3ba80c90026c606c80382c4aafdcfb">00306</a> <span class="preprocessor">#define dlseq_full(head) \</span>
<a name="l00307"></a>00307 <span class="preprocessor">    ((head)-&gt;last &gt;= (head)-&gt;end &amp;&amp; \</span>
<a name="l00308"></a>00308 <span class="preprocessor">     (head)-&gt;first &lt;= (head)-&gt;base)</span>
<a name="l00309"></a>00309 <span class="preprocessor"></span>
<a name="l00318"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga770435a02333a6ec38a68feb239ce2c1">00318</a> <span class="preprocessor">#define dlseq_singular(head) \</span>
<a name="l00319"></a>00319 <span class="preprocessor">    ((head)-&gt;last == ((head)-&gt;first + 1))</span>
<a name="l00320"></a>00320 <span class="preprocessor"></span>
<a name="l00329"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga8de169a8b75e0224c0165711ca292a86">00329</a> <span class="preprocessor">#define dlseq_sortable(head) \</span>
<a name="l00330"></a>00330 <span class="preprocessor">    ((head)-&gt;last &gt; ((head)-&gt;first + 1))</span>
<a name="l00331"></a>00331 <span class="preprocessor"></span>
<a name="l00341"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga875099205528c98db45f9b1aeeb9447b">00341</a> <span class="preprocessor">#define dlseq_insertable(head, cnt) \</span>
<a name="l00342"></a>00342 <span class="preprocessor">    (dlseq_size(head) &gt;= (dlseq_count(head) + (cnt)))</span>
<a name="l00343"></a>00343 <span class="preprocessor"></span>
<a name="l00352"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gad422c134a4ced1d538b07e6298bc6e2c">00352</a> <span class="preprocessor">#define dlseq_serialable(head) \</span>
<a name="l00353"></a>00353 <span class="preprocessor">    ((head)-&gt;last &gt; (head)-&gt;first)</span>
<a name="l00354"></a>00354 <span class="preprocessor"></span>
<a name="l00364"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gad547e1522c3eab4845970c2cb2ff8ec1">00364</a> <span class="preprocessor">#define dlseq_copyable(dst, src) \</span>
<a name="l00365"></a>00365 <span class="preprocessor">    __dlseq_copyable((char*)(dst),              \</span>
<a name="l00366"></a>00366 <span class="preprocessor">                     (char*)(src),              \</span>
<a name="l00367"></a>00367 <span class="preprocessor">                     (char*)((src)-&gt;first),     \</span>
<a name="l00368"></a>00368 <span class="preprocessor">                     (char*)((src)-&gt;last),      \</span>
<a name="l00369"></a>00369 <span class="preprocessor">                     (char*)((dst)-&gt;base),      \</span>
<a name="l00370"></a>00370 <span class="preprocessor">                     (char*)((dst)-&gt;end))</span>
<a name="l00371"></a>00371 <span class="preprocessor"></span>
<a name="l00372"></a>00372 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> __dlseq_copyable(<span class="keywordtype">char</span>* dst, <span class="keywordtype">char</span>* src,
<a name="l00373"></a>00373                                    <span class="keywordtype">char</span>* s_first, <span class="keywordtype">char</span>* s_last,
<a name="l00374"></a>00374                                    <span class="keywordtype">char</span>* d_base, <span class="keywordtype">char</span>* d_end)
<a name="l00375"></a>00375 {
<a name="l00376"></a>00376     <span class="keywordflow">return</span> (dst != src &amp;&amp; (s_last &gt; s_first) &amp;&amp;
<a name="l00377"></a>00377          (d_end - d_base) &gt;= (s_last - s_first));
<a name="l00378"></a>00378 }
<a name="l00379"></a>00379 
<a name="l00386"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gad1795ff276106c853f99d2d07cc56f55">00386</a> <span class="preprocessor">#define dlseq_at(head, index) ((head)-&gt;first + (index))</span>
<a name="l00387"></a>00387 <span class="preprocessor"></span>
<a name="l00395"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gaf6cbffa09f64b0f662d7aec3388a6181">00395</a> <span class="preprocessor">#define dlseq_reverse_at(head, index) \</span>
<a name="l00396"></a>00396 <span class="preprocessor">    ((head)-&gt;last - ((index) + 1))</span>
<a name="l00397"></a>00397 <span class="preprocessor"></span>
<a name="l00404"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gadf3fc42eed9528f855e6177475a000cc">00404</a> <span class="preprocessor">#define dlseq_index_of(head, itr) ((itr) - (head)-&gt;first)</span>
<a name="l00405"></a>00405 <span class="preprocessor"></span>
<a name="l00413"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga8b69fd9bf58887771467282d840fff39">00413</a> <span class="preprocessor">#define dlseq_reverse_index_of(head, itr) \</span>
<a name="l00414"></a>00414 <span class="preprocessor">    ((head)-&gt;last - ((itr) + 1))</span>
<a name="l00415"></a>00415 <span class="preprocessor"></span>
<a name="l00425"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga7459e680b7dff4ea06a41e6d1a72d8e3">00425</a> <span class="preprocessor">#define dlseq_exist(head, itr) \</span>
<a name="l00426"></a>00426 <span class="preprocessor">    __dlseq_exist((char*)((head)-&gt;first),   \</span>
<a name="l00427"></a>00427 <span class="preprocessor">                  (char*)((head)-&gt;last),    \</span>
<a name="l00428"></a>00428 <span class="preprocessor">                  (char*)(itr))</span>
<a name="l00429"></a>00429 <span class="preprocessor"></span>
<a name="l00430"></a>00430 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> __dlseq_exist(<span class="keywordtype">char</span>* first, <span class="keywordtype">char</span>* last, <span class="keywordtype">char</span>* itr)
<a name="l00431"></a>00431 {
<a name="l00432"></a>00432     <span class="keywordflow">return</span> itr &gt;= first &amp;&amp; itr &lt; last;
<a name="l00433"></a>00433 }
<a name="l00434"></a>00434 
<a name="l00443"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gac00cf6a77aa59cf460e06270212b6aec">00443</a> <span class="preprocessor">#define dlseq_distance(first, last) ((size_t)((last) - (first)) + 1)</span>
<a name="l00444"></a>00444 <span class="preprocessor"></span>
<a name="l00454"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga2f78c1229cdf3f7d3c294fc0927fe307">00454</a> <span class="preprocessor">#define dlseq_insert(type, head, pos, newly) do {   \</span>
<a name="l00455"></a>00455 <span class="preprocessor">        type * _q_p = (pos);                        \</span>
<a name="l00456"></a>00456 <span class="preprocessor">        type * _q_f = (head)-&gt;first;                \</span>
<a name="l00457"></a>00457 <span class="preprocessor">        type * _q_b = (head)-&gt;base;                 \</span>
<a name="l00458"></a>00458 <span class="preprocessor">        if (_q_f &gt; _q_b) {                          \</span>
<a name="l00459"></a>00459 <span class="preprocessor">            memcpy(_q_f - 1, _q_f, sizeof(type) *   \</span>
<a name="l00460"></a>00460 <span class="preprocessor">                ((_q_p--) - ((head)-&gt;first--)));    \</span>
<a name="l00461"></a>00461 <span class="preprocessor">        } else {                                    \</span>
<a name="l00462"></a>00462 <span class="preprocessor">            memmove(_q_p + 1, _q_p, sizeof(type) *  \</span>
<a name="l00463"></a>00463 <span class="preprocessor">                (((head)-&gt;last++) - _q_p));          \</span>
<a name="l00464"></a>00464 <span class="preprocessor">        }                                           \</span>
<a name="l00465"></a>00465 <span class="preprocessor">        *_q_p = (newly);                            \</span>
<a name="l00466"></a>00466 <span class="preprocessor">    } while (0)</span>
<a name="l00467"></a>00467 <span class="preprocessor"></span>
<a name="l00475"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga2a6d392893da6b1cd4fc77aba5f698b8">00475</a> <span class="preprocessor">#define dlseq_erase(type, head, pos) do {                       \</span>
<a name="l00476"></a>00476 <span class="preprocessor">        type * _q_p = (pos);                                    \</span>
<a name="l00477"></a>00477 <span class="preprocessor">        type * _q_f = (head)-&gt;first;                            \</span>
<a name="l00478"></a>00478 <span class="preprocessor">        if (((_q_p - _q_f) &lt;&lt; 2) &lt;= ((head)-&gt;last - _q_f)) {    \</span>
<a name="l00479"></a>00479 <span class="preprocessor">            memmove(_q_f + 1, _q_f, sizeof(type) *              \</span>
<a name="l00480"></a>00480 <span class="preprocessor">                (_q_p - ((head)-&gt;first++)));                    \</span>
<a name="l00481"></a>00481 <span class="preprocessor">        } else {                                                \</span>
<a name="l00482"></a>00482 <span class="preprocessor">            memcpy(_q_p, _q_p + 1, sizeof(type) *               \</span>
<a name="l00483"></a>00483 <span class="preprocessor">                ((--(head)-&gt;last) - _q_p));                     \</span>
<a name="l00484"></a>00484 <span class="preprocessor">        }                                                       \</span>
<a name="l00485"></a>00485 <span class="preprocessor">    } while (0)</span>
<a name="l00486"></a>00486 <span class="preprocessor"></span>
<a name="l00505"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga301222520cc0fbbc628a7f5459d6d677">00505</a> <span class="preprocessor">#define dlseq_inserts(type, head, pos, src, cnt) do {                   \</span>
<a name="l00506"></a>00506 <span class="preprocessor">        size_t _q_c = (cnt);                                            \</span>
<a name="l00507"></a>00507 <span class="preprocessor">        type * _q_p = (pos);                                            \</span>
<a name="l00508"></a>00508 <span class="preprocessor">        type * _q_f = (head)-&gt;first;                                    \</span>
<a name="l00509"></a>00509 <span class="preprocessor">        type * _q_b = (head)-&gt;base;                                     \</span>
<a name="l00510"></a>00510 <span class="preprocessor">        if (_q_f &gt;= _q_b + _q_c) {                                      \</span>
<a name="l00511"></a>00511 <span class="preprocessor">            memcpy(_q_f - _q_c, _q_f, sizeof(type) * (_q_p - _q_f));    \</span>
<a name="l00512"></a>00512 <span class="preprocessor">            memcpy(_q_p - _q_c, src, sizeof(type) * _q_c);              \</span>
<a name="l00513"></a>00513 <span class="preprocessor">            (head)-&gt;first -= _q_c;                                      \</span>
<a name="l00514"></a>00514 <span class="preprocessor">        } else if (_q_f &gt; _q_b) {                                       \</span>
<a name="l00515"></a>00515 <span class="preprocessor">            memcpy(_q_b, _q_f, sizeof(type) * (_q_p - _q_f));           \</span>
<a name="l00516"></a>00516 <span class="preprocessor">            memmove(_q_p + (_q_c - (_q_f - _q_b)), _q_p,                \</span>
<a name="l00517"></a>00517 <span class="preprocessor">                sizeof(type) * ((head)-&gt;last - _q_p));                  \</span>
<a name="l00518"></a>00518 <span class="preprocessor">            memcpy(_q_p + (_q_p - _q_f), src, sizeof(type) * _q_c);     \</span>
<a name="l00519"></a>00519 <span class="preprocessor">            (head)-&gt;first = _q_b;                                       \</span>
<a name="l00520"></a>00520 <span class="preprocessor">            (head)-&gt;last += (_q_c - (_q_f - _q_b));                     \</span>
<a name="l00521"></a>00521 <span class="preprocessor">        } else {                                                        \</span>
<a name="l00522"></a>00522 <span class="preprocessor">            memmove(_q_p + _q_c, _q_p, sizeof(type) *                   \</span>
<a name="l00523"></a>00523 <span class="preprocessor">                ((head)-&gt;last - _q_p));                                 \</span>
<a name="l00524"></a>00524 <span class="preprocessor">            memcpy(_q_p, src, sizeof(type) * _q_c);                     \</span>
<a name="l00525"></a>00525 <span class="preprocessor">            (head)-&gt;last += _q_c;                                       \</span>
<a name="l00526"></a>00526 <span class="preprocessor">        }                                                               \</span>
<a name="l00527"></a>00527 <span class="preprocessor">    } while (0)</span>
<a name="l00528"></a>00528 <span class="preprocessor"></span>
<a name="l00537"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga13b81f9dcaa7ff0b0592d56d28814760">00537</a> <span class="preprocessor">#define dlseq_erases(type, head, _begin, _end) do {             \</span>
<a name="l00538"></a>00538 <span class="preprocessor">        type * _q_e = (_end);                                   \</span>
<a name="l00539"></a>00539 <span class="preprocessor">        type * _q_f = (_begin);                                 \</span>
<a name="l00540"></a>00540 <span class="preprocessor">        size_t _q_fr = _q_f - (head)-&gt;first;                    \</span>
<a name="l00541"></a>00541 <span class="preprocessor">        size_t _q_br = (head)-&gt;end - _q_e;                      \</span>
<a name="l00542"></a>00542 <span class="preprocessor">        size_t _q_c = _q_e - _q_f;                              \</span>
<a name="l00543"></a>00543 <span class="preprocessor">        if ((_q_fr &lt;&lt; 1) &lt;= _q_br) {                            \</span>
<a name="l00544"></a>00544 <span class="preprocessor">            memmove((head)-&gt;first + _q_fr, (head)-&gt;first,       \</span>
<a name="l00545"></a>00545 <span class="preprocessor">                sizeof(type) * _q_fr);                          \</span>
<a name="l00546"></a>00546 <span class="preprocessor">            (head)-&gt;first += _q_c;                              \</span>
<a name="l00547"></a>00547 <span class="preprocessor">        } else {                                                \</span>
<a name="l00548"></a>00548 <span class="preprocessor">            memcpy(_q_e - _q_c, _q_e, sizeof(type) * _q_br);    \</span>
<a name="l00549"></a>00549 <span class="preprocessor">            (head)-&gt;last -= _q_c;                               \</span>
<a name="l00550"></a>00550 <span class="preprocessor">        }                                                       \</span>
<a name="l00551"></a>00551 <span class="preprocessor">    } while (0)</span>
<a name="l00552"></a>00552 <span class="preprocessor"></span>
<a name="l00564"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gaac57c5095ae4294fe288ad938fac61d4">00564</a> <span class="preprocessor">#define dlseq_splice(type, dst, pos, src, _first, _last) do {       \</span>
<a name="l00565"></a>00565 <span class="preprocessor">        type * _q1_l = (_last);                                     \</span>
<a name="l00566"></a>00566 <span class="preprocessor">        type * _q1_f = (_first);                                    \</span>
<a name="l00567"></a>00567 <span class="preprocessor">        dlseq_inserts(type, dst, pos, _q1_f, _q1_l - _q1_f + 1);    \</span>
<a name="l00568"></a>00568 <span class="preprocessor">        dlseq_erases(type, src, _q1_f, _q1_l + 1);                  \</span>
<a name="l00569"></a>00569 <span class="preprocessor">    } while (0)</span>
<a name="l00570"></a>00570 <span class="preprocessor"></span>
<a name="l00587"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gab676285a57db869dccb71427c0654794">00587</a> <span class="preprocessor">#define dlseq_appends(type, head, src, cnt) do {        \</span>
<a name="l00588"></a>00588 <span class="preprocessor">        size_t _q_c = (cnt);                            \</span>
<a name="l00589"></a>00589 <span class="preprocessor">        memcpy((head)-&gt;last, src, sizeof(type) * _q_c); \</span>
<a name="l00590"></a>00590 <span class="preprocessor">        (head)-&gt;last += _q_c;                           \</span>
<a name="l00591"></a>00591 <span class="preprocessor">    } while (0)</span>
<a name="l00592"></a>00592 <span class="preprocessor"></span>
<a name="l00600"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga80ce7977d2edd851be98ded3c8390030">00600</a> <span class="preprocessor">#define dlseq_append(head, newly) \</span>
<a name="l00601"></a>00601 <span class="preprocessor">    (*((head)-&gt;last++) = (newly))</span>
<a name="l00602"></a>00602 <span class="preprocessor"></span>
<a name="l00618"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gac5a831831e84c67739553b3de4e252d9">00618</a> <span class="preprocessor">#define dlseq_copy(type, dst, src) do {                         \</span>
<a name="l00619"></a>00619 <span class="preprocessor">        size_t _q_c = dlseq_count(src);                         \</span>
<a name="l00620"></a>00620 <span class="preprocessor">        memcpy((dst)-&gt;base, (src)-&gt;first, sizeof(type) * _q_c); \</span>
<a name="l00621"></a>00621 <span class="preprocessor">        (dst)-&gt;last = ((dst)-&gt;first = (dst)-&gt;base) + _q_c;      \</span>
<a name="l00622"></a>00622 <span class="preprocessor">    } while (0)</span>
<a name="l00623"></a>00623 <span class="preprocessor"></span>
<a name="l00636"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga1ffc7ba150c4254c36b1bceb1f3e0ba3">00636</a> <span class="preprocessor">#define dlseq_push_front(head) (--(head)-&gt;first)</span>
<a name="l00637"></a>00637 <span class="preprocessor"></span>
<a name="l00650"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga65bbbab96c82c62d05b0412cb2c263a1">00650</a> <span class="preprocessor">#define dlseq_push_back(head) ((head)-&gt;last++)</span>
<a name="l00651"></a>00651 <span class="preprocessor"></span>
<a name="l00664"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gac73e9d7e34f9441d1a0c9f85dfc8ca65">00664</a> <span class="preprocessor">#define dlseq_pop_front(head) ((head)-&gt;first++)</span>
<a name="l00665"></a>00665 <span class="preprocessor"></span>
<a name="l00678"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga359a8bae60736d1abd3211cb526cb295">00678</a> <span class="preprocessor">#define dlseq_pop_back(head) (--(head)-&gt;last)</span>
<a name="l00679"></a>00679 <span class="preprocessor"></span>
<a name="l00686"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga47b7a737affe0b4d4254330362a639d3">00686</a> <span class="preprocessor">#define dlseq_iter_replace(victim, newly) (*(victim) = (newly))</span>
<a name="l00687"></a>00687 <span class="preprocessor"></span>
<a name="l00688"></a>00688 <span class="preprocessor">#define __dlseq_iter_swap(type, a, b) do {\</span>
<a name="l00689"></a>00689 <span class="preprocessor">    type _q_t = *(a); *(a) = *(b); *(b) = _q_t; } while (0)</span>
<a name="l00690"></a>00690 <span class="preprocessor"></span>
<a name="l00698"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gaf1ec6d8c982f4c3b3bf9a774f3556d83">00698</a> <span class="preprocessor">#define dlseq_iter_swap(type, a, b) do {        \</span>
<a name="l00699"></a>00699 <span class="preprocessor">        type * _q_b = (b); type * _q_a = (a);   \</span>
<a name="l00700"></a>00700 <span class="preprocessor">        __dlseq_iter_swap(type, _q_a, _q_b);    \</span>
<a name="l00701"></a>00701 <span class="preprocessor">    } while (0)</span>
<a name="l00702"></a>00702 <span class="preprocessor"></span>
<a name="l00709"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga93f49440956f625d85ecd6c56a6a557b">00709</a> <span class="preprocessor">#define dlseq_replace(victim, newly) (*(victim) = *(newly))</span>
<a name="l00710"></a>00710 <span class="preprocessor"></span>
<a name="l00718"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga3b6c7e04f4f0b4f09a2dfd96cdbd2f48">00718</a> <span class="preprocessor">#define dlseq_swap(type, a, b) do { \</span>
<a name="l00719"></a>00719 <span class="preprocessor">        dlseq_head(type) t = *(a);  \</span>
<a name="l00720"></a>00720 <span class="preprocessor">        *(a) = *(b); *(b) = t;      \</span>
<a name="l00721"></a>00721 <span class="preprocessor">    } while (0)</span>
<a name="l00722"></a>00722 <span class="preprocessor"></span>
<a name="l00729"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga75e1528caa8626fb419cca8dc20cdf92">00729</a> <span class="preprocessor">#define dlseq_front(head) ((head)-&gt;first)</span>
<a name="l00730"></a>00730 <span class="preprocessor"></span>
<a name="l00738"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga32ba395611eaf4595297f01765cc46b3">00738</a> <span class="preprocessor">#define dlseq_back(head) ((head)-&gt;last - 1)</span>
<a name="l00739"></a>00739 <span class="preprocessor"></span>
<a name="l00756"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga6474f4beeadeb8b3be6baa1a375a16ed">00756</a> <span class="preprocessor">#define dlseq_begin(head) dlseq_front(head)</span>
<a name="l00757"></a>00757 <span class="preprocessor"></span>
<a name="l00765"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga8df3a77782b4f5626a1e3a8c6f0aa18d">00765</a> <span class="preprocessor">#define dlseq_end(head) ((head)-&gt;last)</span>
<a name="l00766"></a>00766 <span class="preprocessor"></span>
<a name="l00774"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gad46f419b47937396e808b278b799c9a1">00774</a> <span class="preprocessor">#define dlseq_end_of(itr) ((itr) + 1)</span>
<a name="l00775"></a>00775 <span class="preprocessor"></span>
<a name="l00783"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga8985a9f0fe4e6ad0604812db85008bf5">00783</a> <span class="preprocessor">#define dlseq_rbegin(head) dlseq_back(head)</span>
<a name="l00784"></a>00784 <span class="preprocessor"></span>
<a name="l00791"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gacddec11d890f47536009ac2c4a4be320">00791</a> <span class="preprocessor">#define dlseq_rend(head) ((head)-&gt;first - 1)</span>
<a name="l00792"></a>00792 <span class="preprocessor"></span>
<a name="l00800"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gae4d086dbf72b7d1a1e5a3e60bf1240c5">00800</a> <span class="preprocessor">#define dlseq_rend_of(itr) ((itr) - 1)</span>
<a name="l00801"></a>00801 <span class="preprocessor"></span>
<a name="l00809"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga9ce07f7c9c2517cc61557bb9ee5d1248">00809</a> <span class="preprocessor">#define dlseq_next(itr) ((itr) + 1)</span>
<a name="l00810"></a>00810 <span class="preprocessor"></span>
<a name="l00818"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga333294fd96e85f7314e6f6cc7e5f9d82">00818</a> <span class="preprocessor">#define dlseq_prev(itr) ((itr) - 1)</span>
<a name="l00819"></a>00819 <span class="preprocessor"></span>
<a name="l00827"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga8d6b85ec3412d57a90c7af5282a7bfd6">00827</a> <span class="preprocessor">#define dlseq_advance(cur, dist) ((cur) + (dist))</span>
<a name="l00828"></a>00828 <span class="preprocessor"></span>
<a name="l00853"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga643c9d33c7a1ac060d44dda56ae11c4f">00853</a> <span class="preprocessor">#define DLSEQ_NOT_END(itr, end)     ((itr) &lt; (end))</span>
<a name="l00854"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga51fa2c1938f25c3658d8bbd5c75f9c9b">00854</a> <span class="preprocessor"></span><span class="preprocessor">#define DLSEQ_NOT_REND(itr, rend)   ((itr) &gt; (rend))</span>
<a name="l00855"></a>00855 <span class="preprocessor"></span>
<a name="l00886"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga01ab03ece963941926de7996cdb7f1c0">00886</a> <span class="preprocessor">#define dlseq_inc(itr)              (++(itr))</span>
<a name="l00887"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga37f4f964e40c0127fe53f972c1ce3564">00887</a> <span class="preprocessor"></span><span class="preprocessor">#define dlseq_dec(itr)              (--(itr))</span>
<a name="l00888"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gaa6bb2aa8b6e1b9eecba00c50135fc17b">00888</a> <span class="preprocessor"></span><span class="preprocessor">#define dlseq_add(itr, cnt)         ((itr) += (cnt))</span>
<a name="l00889"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga387e19749450fd5d184daa1fa55f616e">00889</a> <span class="preprocessor"></span><span class="preprocessor">#define dlseq_sub(itr, cnt)         ((itr) -= (cnt))</span>
<a name="l00890"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga5ac7e6ad6068260172a91d0cdd6409d0">00890</a> <span class="preprocessor"></span><span class="preprocessor">#define dlseq_inc_later(itr)        ((itr)++)</span>
<a name="l00891"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gad5280822494b200f031a16a1312505b2">00891</a> <span class="preprocessor"></span><span class="preprocessor">#define dlseq_dec_later(itr)        ((itr)--)</span>
<a name="l00892"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga6c72b56a6426b9cca6aa338282809b5a">00892</a> <span class="preprocessor"></span><span class="preprocessor">#define dlseq_add_later(itr, cnt)   (dlseq_add(itr, cnt) - (cnt))</span>
<a name="l00893"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga892a66d0a679113f3959bdc30528c218">00893</a> <span class="preprocessor"></span><span class="preprocessor">#define dlseq_sub_later(itr, cnt)   (dlseq_sub(itr, cnt) + (cnt))</span>
<a name="l00894"></a>00894 <span class="preprocessor"></span>
<a name="l00904"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga831b9c1bcf432adf5a9856f0415464f0">00904</a> <span class="preprocessor">#define dlseq_foreach(type, begin, end, fn) \</span>
<a name="l00905"></a>00905 <span class="preprocessor">    do {type * _q_e = (type *)(end);        \</span>
<a name="l00906"></a>00906 <span class="preprocessor">        type * _q_f = (type *)(begin);      \</span>
<a name="l00907"></a>00907 <span class="preprocessor">        while (_q_f &lt; _q_e) {               \</span>
<a name="l00908"></a>00908 <span class="preprocessor">            fn(_q_f);                       \</span>
<a name="l00909"></a>00909 <span class="preprocessor">            ++_q_f;                         \</span>
<a name="l00910"></a>00910 <span class="preprocessor">        }                                   \</span>
<a name="l00911"></a>00911 <span class="preprocessor">    } while(0)</span>
<a name="l00912"></a>00912 <span class="preprocessor"></span>
<a name="l00922"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gad4ff379776899de6d39d9aa14fe34993">00922</a> <span class="preprocessor">#define dlseq_reverse_foreach(type, rbegin, rend, fn) \</span>
<a name="l00923"></a>00923 <span class="preprocessor">    do {type * _q_e = (type *)(rend);       \</span>
<a name="l00924"></a>00924 <span class="preprocessor">        type * _q_f = (type *)(rbegin);     \</span>
<a name="l00925"></a>00925 <span class="preprocessor">        while (_q_f &gt; _q_e) {               \</span>
<a name="l00926"></a>00926 <span class="preprocessor">            fn(_q_f);                       \</span>
<a name="l00927"></a>00927 <span class="preprocessor">            --_q_f;                         \</span>
<a name="l00928"></a>00928 <span class="preprocessor">        }                                   \</span>
<a name="l00929"></a>00929 <span class="preprocessor">    } while(0)</span>
<a name="l00930"></a>00930 <span class="preprocessor"></span>
<a name="l00943"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga39a31078b854331a7545bf39fca28e1c">00943</a> <span class="preprocessor">#define dlseq_search(type, begin, end, equal, var, res) \</span>
<a name="l00944"></a>00944 <span class="preprocessor">    do {type _q_t = (var);                      \</span>
<a name="l00945"></a>00945 <span class="preprocessor">        type * _q_e = (end);                    \</span>
<a name="l00946"></a>00946 <span class="preprocessor">        type * _q_f = (begin);                  \</span>
<a name="l00947"></a>00947 <span class="preprocessor">        (res) = NULL;                           \</span>
<a name="l00948"></a>00948 <span class="preprocessor">        while (_q_f &lt; _q_e) {                   \</span>
<a name="l00949"></a>00949 <span class="preprocessor">            type * _q_cb = _q_f++;              \</span>
<a name="l00950"></a>00950 <span class="preprocessor">            if (equal(_q_cb, (&amp;_q_t))) {        \</span>
<a name="l00951"></a>00951 <span class="preprocessor">                (res) = _q_cb;                  \</span>
<a name="l00952"></a>00952 <span class="preprocessor">                break;                          \</span>
<a name="l00953"></a>00953 <span class="preprocessor">            }                                   \</span>
<a name="l00954"></a>00954 <span class="preprocessor">        }                                       \</span>
<a name="l00955"></a>00955 <span class="preprocessor">    } while (0)</span>
<a name="l00956"></a>00956 <span class="preprocessor"></span>
<a name="l00969"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga1ca62ed17125c8f59557e1b970fd4d45">00969</a> <span class="preprocessor">#define dlseq_binary_search(type, begin, end, greater, var, res) \</span>
<a name="l00970"></a>00970 <span class="preprocessor">    do {type _q_t = (var);                                  \</span>
<a name="l00971"></a>00971 <span class="preprocessor">        type * _q_e = (end);                                \</span>
<a name="l00972"></a>00972 <span class="preprocessor">        type * _q_f = (begin);                              \</span>
<a name="l00973"></a>00973 <span class="preprocessor">        (res) = NULL;                                       \</span>
<a name="l00974"></a>00974 <span class="preprocessor">        while (_q_f &lt; _q_e) {                               \</span>
<a name="l00975"></a>00975 <span class="preprocessor">            type * _q_m = _q_f + ((_q_e - _q_f) &gt;&gt; 1);      \</span>
<a name="l00976"></a>00976 <span class="preprocessor">            if (greater(_q_m, (&amp;_q_t))) {                   \</span>
<a name="l00977"></a>00977 <span class="preprocessor">                _q_e = _q_m;                                \</span>
<a name="l00978"></a>00978 <span class="preprocessor">            } else if (greater((&amp;_q_t), _q_m)) {            \</span>
<a name="l00979"></a>00979 <span class="preprocessor">                _q_f = _q_m + 1;                            \</span>
<a name="l00980"></a>00980 <span class="preprocessor">            } else {                                        \</span>
<a name="l00981"></a>00981 <span class="preprocessor">                (res) = _q_m;                               \</span>
<a name="l00982"></a>00982 <span class="preprocessor">                break;                                      \</span>
<a name="l00983"></a>00983 <span class="preprocessor">            }                                               \</span>
<a name="l00984"></a>00984 <span class="preprocessor">        }                                                   \</span>
<a name="l00985"></a>00985 <span class="preprocessor">    } while (0)</span>
<a name="l00986"></a>00986 <span class="preprocessor"></span>
<a name="l00987"></a>00987 <span class="comment">/* 反转序表的两种方式：</span>
<a name="l00988"></a>00988 <span class="comment"> * (1) 直接使用 dlseq_reverse(元素类型, head); (推荐)</span>
<a name="l00989"></a>00989 <span class="comment"> * (2) 按照如下方式迭代</span>
<a name="l00990"></a>00990 <span class="comment"> *     dlseq_iter(int) i = dlseq_vbegin(head);</span>
<a name="l00991"></a>00991 <span class="comment"> *     dlseq_iter(int) j = dlseq_rvbegin(head);</span>
<a name="l00992"></a>00992 <span class="comment"> *     dlseq_iter(int) e = dlseq_vend(head);</span>
<a name="l00993"></a>00993 <span class="comment"> *     while (i &lt; e) {</span>
<a name="l00994"></a>00994 <span class="comment"> *          dlseq_vswap(元素类型, i, j);</span>
<a name="l00995"></a>00995 <span class="comment"> *     }</span>
<a name="l00996"></a>00996 <span class="comment"> *     当迭代完成时，反转完成</span>
<a name="l00997"></a>00997 <span class="comment"> */</span>
<a name="l00998"></a>00998 
<a name="l01020"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga678f3f705968d3f7d63ad6dae67c1a3e">01020</a> <span class="preprocessor">#define dlseq_vbegin(head)      dlseq_begin(head)</span>
<a name="l01021"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga9da7efbb8d187840982f9dcb8cdd6813">01021</a> <span class="preprocessor"></span><span class="preprocessor">#define dlseq_rvbegin(head)     dlseq_rbegin(head)</span>
<a name="l01022"></a>01022 <span class="preprocessor"></span>
<a name="l01040"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga76ba6e93e9250c4f760cdb428c1f9b66">01040</a> <span class="preprocessor">#define dlseq_vend(head) \</span>
<a name="l01041"></a>01041 <span class="preprocessor">    ((head)-&gt;first + (dlseq_count(head) &gt;&gt; 1))</span>
<a name="l01042"></a>01042 <span class="preprocessor"></span>
<a name="l01043"></a>01043 <span class="preprocessor">#define dlseq_vnext(i, r) do { ++(i); --(r); } while (0)</span>
<a name="l01044"></a>01044 <span class="preprocessor"></span>
<a name="l01063"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gaf4891f2fccdd0ceed3bc3051f54951c6">01063</a> <span class="preprocessor">#define dlseq_vswap(type, i, r) do {    \</span>
<a name="l01064"></a>01064 <span class="preprocessor">        __dlseq_iter_swap(type, i, r);  \</span>
<a name="l01065"></a>01065 <span class="preprocessor">        dlseq_vnext(i, r);              \</span>
<a name="l01066"></a>01066 <span class="preprocessor">    } while (0)</span>
<a name="l01067"></a>01067 <span class="preprocessor"></span>
<a name="l01075"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga4f45f7c4d2ebabb744fbaab175f4128b">01075</a> <span class="preprocessor">#define dlseq_reverse(type, head) do {          \</span>
<a name="l01076"></a>01076 <span class="preprocessor">        type * _q_e = dlseq_vend(head);         \</span>
<a name="l01077"></a>01077 <span class="preprocessor">        type * _q_i = dlseq_vbegin(head);       \</span>
<a name="l01078"></a>01078 <span class="preprocessor">        type * _q_j = dlseq_rvbegin(head);      \</span>
<a name="l01079"></a>01079 <span class="preprocessor">        while (_q_i &lt; _q_e)                     \</span>
<a name="l01080"></a>01080 <span class="preprocessor">            dlseq_vswap(type, _q_i, _q_j);      \</span>
<a name="l01081"></a>01081 <span class="preprocessor">    } while (0)</span>
<a name="l01082"></a>01082 <span class="preprocessor"></span>
<a name="l01091"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga01367e1ec99347d055599c797fb484cd">01091</a> <span class="preprocessor">#define dlseq_serialize(type, head, buf) \</span>
<a name="l01092"></a>01092 <span class="preprocessor">    memcpy(buf, (head)-&gt;first, sizeof(type) * dlseq_count(head))</span>
<a name="l01093"></a>01093 <span class="preprocessor"></span>
<a name="l01103"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga311df7cdf33e89ae2888408ac946827b">01103</a> <span class="preprocessor">#define dlseq_fill(type, begin, end, val) \</span>
<a name="l01104"></a>01104 <span class="preprocessor">    do {type _q_v = (val);      \</span>
<a name="l01105"></a>01105 <span class="preprocessor">        type * _q_e = (end);    \</span>
<a name="l01106"></a>01106 <span class="preprocessor">        type * _q_f = (begin);  \</span>
<a name="l01107"></a>01107 <span class="preprocessor">        while (_q_f &lt; _q_e)     \</span>
<a name="l01108"></a>01108 <span class="preprocessor">            *_q_f++ = _q_v;     \</span>
<a name="l01109"></a>01109 <span class="preprocessor">    } while (0)</span>
<a name="l01110"></a>01110 <span class="preprocessor"></span>
<a name="l01120"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gae59f3e47930b766b879c7b29d0f2218e">01120</a> <span class="preprocessor">#define dlseq_generate(type, begin, end, generator) \</span>
<a name="l01121"></a>01121 <span class="preprocessor">    do {type * _q_e = (end);        \</span>
<a name="l01122"></a>01122 <span class="preprocessor">        type * _q_f = (begin);      \</span>
<a name="l01123"></a>01123 <span class="preprocessor">        while (_q_f &lt; _q_e)         \</span>
<a name="l01124"></a>01124 <span class="preprocessor">            *_q_f++ = (generator);  \</span>
<a name="l01125"></a>01125 <span class="preprocessor">    } while (0)</span>
<a name="l01126"></a>01126 <span class="preprocessor"></span>
<a name="l01139"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gaa7b9575d98c17fcde6612f91f79b953b">01139</a> <span class="preprocessor">#define dlseq_is_heap(type, begin, end, greater, res)   \</span>
<a name="l01140"></a>01140 <span class="preprocessor">    do {type * _q_e = (end);                            \</span>
<a name="l01141"></a>01141 <span class="preprocessor">        type * _q_f = (begin);                          \</span>
<a name="l01142"></a>01142 <span class="preprocessor">        size_t _q_c = _q_e - _q_f;                      \</span>
<a name="l01143"></a>01143 <span class="preprocessor">        type * _q_b = _q_f + ((_q_c - 1) &gt;&gt; 1);         \</span>
<a name="l01144"></a>01144 <span class="preprocessor">        type * _q_p = _q_f;                             \</span>
<a name="l01145"></a>01145 <span class="preprocessor">        type * _q_i = _q_f + 1;                         \</span>
<a name="l01146"></a>01146 <span class="preprocessor">        for ((res) = 1; _q_b-- &gt; _q_f; ++_q_p) {        \</span>
<a name="l01147"></a>01147 <span class="preprocessor">            __dlseq_ret_gt(_q_i, _q_p, res, greater);   \</span>
<a name="l01148"></a>01148 <span class="preprocessor">            __dlseq_ret_gt(_q_i, _q_p, res, greater);   \</span>
<a name="l01149"></a>01149 <span class="preprocessor">        }                                               \</span>
<a name="l01150"></a>01150 <span class="preprocessor">        if (_q_i &lt; _q_e &amp;&amp; (greater(_q_i, _q_p))) {    \</span>
<a name="l01151"></a>01151 <span class="preprocessor">            (res) = 0; break;                           \</span>
<a name="l01152"></a>01152 <span class="preprocessor">        }                                               \</span>
<a name="l01153"></a>01153 <span class="preprocessor">    } while (0)</span>
<a name="l01154"></a>01154 <span class="preprocessor"></span>
<a name="l01155"></a>01155 <span class="preprocessor">#define __dlseq_ret_gt(i, j, r, greater) \</span>
<a name="l01156"></a>01156 <span class="preprocessor">    if (greater((i), (j))) { (r) = 0; break; } ++(i)</span>
<a name="l01157"></a>01157 <span class="preprocessor"></span>
<a name="l01175"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga54a2e34c3ae32b16f143a305d6e52931">01175</a> <span class="preprocessor">#define dlseq_push_heap(type, begin, end, greater) do { \</span>
<a name="l01176"></a>01176 <span class="preprocessor">        type * _q_l = (type *)(end) - 1;                \</span>
<a name="l01177"></a>01177 <span class="preprocessor">        type * _q_f = (type *)(begin);                  \</span>
<a name="l01178"></a>01178 <span class="preprocessor">        size_t _q_i = _q_l - _q_f;                      \</span>
<a name="l01179"></a>01179 <span class="preprocessor">        size_t _q_p = (_q_i - 1) &gt;&gt; 1;                  \</span>
<a name="l01180"></a>01180 <span class="preprocessor">        type * _q_ib = _q_f + _q_i;                     \</span>
<a name="l01181"></a>01181 <span class="preprocessor">        type * _q_pb = _q_f + _q_p;                     \</span>
<a name="l01182"></a>01182 <span class="preprocessor">        type _q_t = *_q_ib;                             \</span>
<a name="l01183"></a>01183 <span class="preprocessor">        while (_q_i &amp;&amp; (greater((&amp;_q_t), _q_pb))) {   \</span>
<a name="l01184"></a>01184 <span class="preprocessor">            *_q_ib = *_q_pb;                            \</span>
<a name="l01185"></a>01185 <span class="preprocessor">            _q_ib = _q_pb;                              \</span>
<a name="l01186"></a>01186 <span class="preprocessor">            _q_i = _q_p;                                \</span>
<a name="l01187"></a>01187 <span class="preprocessor">            _q_p = (_q_p - 1) &gt;&gt; 1;                     \</span>
<a name="l01188"></a>01188 <span class="preprocessor">            _q_pb = _q_f + _q_p;                        \</span>
<a name="l01189"></a>01189 <span class="preprocessor">        }                                               \</span>
<a name="l01190"></a>01190 <span class="preprocessor">        *_q_ib = _q_t;                                  \</span>
<a name="l01191"></a>01191 <span class="preprocessor">    } while (0)</span>
<a name="l01192"></a>01192 <span class="preprocessor"></span>
<a name="l01208"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga62bf84e92b19a7191b1337f9698b525a">01208</a> <span class="preprocessor">#define dlseq_pop_heap(type, begin, end, greater) do {  \</span>
<a name="l01209"></a>01209 <span class="preprocessor">        type * _q_l = (type *)(end) - 1;                \</span>
<a name="l01210"></a>01210 <span class="preprocessor">        type * _q_f = (type *)(begin);                  \</span>
<a name="l01211"></a>01211 <span class="preprocessor">        type * _q_pb = _q_f;                            \</span>
<a name="l01212"></a>01212 <span class="preprocessor">        type * _q_ib, * _q_jb;                          \</span>
<a name="l01213"></a>01213 <span class="preprocessor">        type _q_t = *_q_pb;                             \</span>
<a name="l01214"></a>01214 <span class="preprocessor">        size_t _q_p = 0, _q_j = 2;                      \</span>
<a name="l01215"></a>01215 <span class="preprocessor">        size_t _q_L = _q_l - _q_f;                      \</span>
<a name="l01216"></a>01216 <span class="preprocessor">        for (; _q_j &lt;= _q_L; _q_j = (_q_p + 1) &lt;&lt; 1) {  \</span>
<a name="l01217"></a>01217 <span class="preprocessor">            _q_jb = _q_f + _q_j;                        \</span>
<a name="l01218"></a>01218 <span class="preprocessor">            _q_ib = _q_jb - 1;                          \</span>
<a name="l01219"></a>01219 <span class="preprocessor">            if (greater(_q_jb, _q_ib)) {                \</span>
<a name="l01220"></a>01220 <span class="preprocessor">                *_q_pb = *_q_jb;                        \</span>
<a name="l01221"></a>01221 <span class="preprocessor">                _q_pb = _q_jb;                          \</span>
<a name="l01222"></a>01222 <span class="preprocessor">                _q_p = _q_j;                            \</span>
<a name="l01223"></a>01223 <span class="preprocessor">            } else {                                    \</span>
<a name="l01224"></a>01224 <span class="preprocessor">                *_q_pb = *_q_ib;                        \</span>
<a name="l01225"></a>01225 <span class="preprocessor">                _q_pb = _q_ib;                          \</span>
<a name="l01226"></a>01226 <span class="preprocessor">                _q_p = _q_j - 1;                        \</span>
<a name="l01227"></a>01227 <span class="preprocessor">            }                                           \</span>
<a name="l01228"></a>01228 <span class="preprocessor">        }                                               \</span>
<a name="l01229"></a>01229 <span class="preprocessor">        _q_jb = _q_f + ((_q_p - 1) &gt;&gt; 1);               \</span>
<a name="l01230"></a>01230 <span class="preprocessor">        if (greater(_q_l, _q_jb)) {                     \</span>
<a name="l01231"></a>01231 <span class="preprocessor">            *_q_pb = *_q_jb;                            \</span>
<a name="l01232"></a>01232 <span class="preprocessor">            *_q_jb = *_q_l;                             \</span>
<a name="l01233"></a>01233 <span class="preprocessor">        } else                                          \</span>
<a name="l01234"></a>01234 <span class="preprocessor">            *_q_pb = *_q_l;                             \</span>
<a name="l01235"></a>01235 <span class="preprocessor">        *_q_l = _q_t;                                   \</span>
<a name="l01236"></a>01236 <span class="preprocessor">    } while (0)</span>
<a name="l01237"></a>01237 <span class="preprocessor"></span>
<a name="l01238"></a>01238 <span class="comment">/* 下滤调整：</span>
<a name="l01239"></a>01239 <span class="comment"> * (1)将first记为parent节点.</span>
<a name="l01240"></a>01240 <span class="comment"> * (2)若parent节点有两个子节点，则选出值最大节点，记为max，</span>
<a name="l01241"></a>01241 <span class="comment"> *    若parent节点仅一个子节点，则选唯一节点为最大节点，记为max，</span>
<a name="l01242"></a>01242 <span class="comment"> *    若parent节点没有子节点，则退出算法.</span>
<a name="l01243"></a>01243 <span class="comment"> * (3)若parent节点的值大于等于max节点的值，则退出算法.</span>
<a name="l01244"></a>01244 <span class="comment"> * (4)将max节点与parent节点的值进行交换.</span>
<a name="l01245"></a>01245 <span class="comment"> * (5)将max节点记为parent节点，转(2).</span>
<a name="l01246"></a>01246 <span class="comment"> * greater(i, j) 最大堆 =&gt; (*i &gt; *j) 最小堆 =&gt; (*i &lt; *j)</span>
<a name="l01247"></a>01247 <span class="comment"> */</span>
<a name="l01248"></a>01248 <span class="preprocessor">#define __dlseq_adjust_heap(type, base, first, last, greater) \</span>
<a name="l01249"></a>01249 <span class="preprocessor">    do {size_t _q_j = ((first) + 1) &lt;&lt; 1;           \</span>
<a name="l01250"></a>01250 <span class="preprocessor">        type * _q_pb = (base) + (first);            \</span>
<a name="l01251"></a>01251 <span class="preprocessor">        type * _q_lb = (base) + (last);             \</span>
<a name="l01252"></a>01252 <span class="preprocessor">        type * _q_ib, * _q_jb, * _q_mb;             \</span>
<a name="l01253"></a>01253 <span class="preprocessor">        type _q_t = *_q_pb;                         \</span>
<a name="l01254"></a>01254 <span class="preprocessor">        while (_q_j &lt;= (last)) {                    \</span>
<a name="l01255"></a>01255 <span class="preprocessor">            _q_jb = (base) + _q_j;                  \</span>
<a name="l01256"></a>01256 <span class="preprocessor">            _q_ib = _q_jb - 1;                      \</span>
<a name="l01257"></a>01257 <span class="preprocessor">            if (greater(_q_jb, _q_ib)) {            \</span>
<a name="l01258"></a>01258 <span class="preprocessor">                _q_mb = _q_jb;                      \</span>
<a name="l01259"></a>01259 <span class="preprocessor">                _q_j = (_q_j + 1) &lt;&lt; 1;             \</span>
<a name="l01260"></a>01260 <span class="preprocessor">            } else {                                \</span>
<a name="l01261"></a>01261 <span class="preprocessor">                _q_mb = _q_ib;                      \</span>
<a name="l01262"></a>01262 <span class="preprocessor">                _q_j = _q_j &lt;&lt; 1;                   \</span>
<a name="l01263"></a>01263 <span class="preprocessor">            }                                       \</span>
<a name="l01264"></a>01264 <span class="preprocessor">            if (greater((&amp;_q_t), _q_mb))            \</span>
<a name="l01265"></a>01265 <span class="preprocessor">                break;                              \</span>
<a name="l01266"></a>01266 <span class="preprocessor">            *_q_pb = *_q_mb;                        \</span>
<a name="l01267"></a>01267 <span class="preprocessor">            _q_pb = _q_mb;                          \</span>
<a name="l01268"></a>01268 <span class="preprocessor">        }                                           \</span>
<a name="l01269"></a>01269 <span class="preprocessor">        if (_q_j == (last) + 1 &amp;&amp;                   \</span>
<a name="l01270"></a>01270 <span class="preprocessor">            (greater(_q_lb, (&amp;_q_t)))) {            \</span>
<a name="l01271"></a>01271 <span class="preprocessor">            *_q_pb = *_q_lb;                        \</span>
<a name="l01272"></a>01272 <span class="preprocessor">            *_q_lb = _q_t;                          \</span>
<a name="l01273"></a>01273 <span class="preprocessor">        } else                                      \</span>
<a name="l01274"></a>01274 <span class="preprocessor">            *_q_pb = _q_t;                          \</span>
<a name="l01275"></a>01275 <span class="preprocessor">    } while (0)</span>
<a name="l01276"></a>01276 <span class="preprocessor"></span>
<a name="l01293"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gafd902927efafe9ca45985b21a6097284">01293</a> <span class="preprocessor">#define dlseq_make_heap(type, begin, end, greater) do {\</span>
<a name="l01294"></a>01294 <span class="preprocessor">        type * _q1_f = (type *)(begin);                                 \</span>
<a name="l01295"></a>01295 <span class="preprocessor">        size_t _q1_l = (type *)(end) - _q1_f - 1;                       \</span>
<a name="l01296"></a>01296 <span class="preprocessor">        size_t _q1_i = ((_q1_l - 1) &gt;&gt; 1) + 1;                          \</span>
<a name="l01297"></a>01297 <span class="preprocessor">        while (_q1_i--)                                                 \</span>
<a name="l01298"></a>01298 <span class="preprocessor">            __dlseq_adjust_heap(type, _q1_f, _q1_i, _q1_l, greater);    \</span>
<a name="l01299"></a>01299 <span class="preprocessor">    } while (0)</span>
<a name="l01300"></a>01300 <span class="preprocessor"></span>
<a name="l01315"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gaeed9eecdd875ae3bae1e27ca01de5cd7">01315</a> <span class="preprocessor">#define dlseq_sort_heap(type, begin, end, greater) do {     \</span>
<a name="l01316"></a>01316 <span class="preprocessor">        type * _q1_e = (end);                               \</span>
<a name="l01317"></a>01317 <span class="preprocessor">        type * _q1_f = (begin);                             \</span>
<a name="l01318"></a>01318 <span class="preprocessor">        while (_q1_e &gt; _q1_f + 1) {                         \</span>
<a name="l01319"></a>01319 <span class="preprocessor">            dlseq_pop_heap(type, _q1_f, _q1_e--, greater);  \</span>
<a name="l01320"></a>01320 <span class="preprocessor">        }                                                   \</span>
<a name="l01321"></a>01321 <span class="preprocessor">    } while (0)</span>
<a name="l01322"></a>01322 <span class="preprocessor"></span>
<a name="l01331"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga9777d7ab606e4f51bbdbf972da459396">01331</a> <span class="preprocessor">#define dlseq_shuffle(type, begin, end, _RAND) do {     \</span>
<a name="l01332"></a>01332 <span class="preprocessor">        type * _q_l = (type *)(end) - 1;                \</span>
<a name="l01333"></a>01333 <span class="preprocessor">        type * _q_f = (type *)(begin);                  \</span>
<a name="l01334"></a>01334 <span class="preprocessor">        for (; _q_l &gt; _q_f; --_q_l) {                   \</span>
<a name="l01335"></a>01335 <span class="preprocessor">            type * _q_n = _q_f +                        \</span>
<a name="l01336"></a>01336 <span class="preprocessor">                ((_RAND) % ((_q_l - _q_f) + 1));        \</span>
<a name="l01337"></a>01337 <span class="preprocessor">            if (_q_l &gt; _q_n)                            \</span>
<a name="l01338"></a>01338 <span class="preprocessor">                __dlseq_iter_swap(type, _q_l, _q_n);    \</span>
<a name="l01339"></a>01339 <span class="preprocessor">        }                                               \</span>
<a name="l01340"></a>01340 <span class="preprocessor">    } while (0)</span>
<a name="l01341"></a>01341 <span class="preprocessor"></span>
<a name="l01350"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga4aed9d38a685cd50a50a146b80c906d9">01350</a> <span class="preprocessor">#define dlseq_sort_insert(type, head, begin, end, newly, greater_equal) \</span>
<a name="l01351"></a>01351 <span class="preprocessor">    do {type _q_n = (newly);                    \</span>
<a name="l01352"></a>01352 <span class="preprocessor">        type * _q_e = (end);                    \</span>
<a name="l01353"></a>01353 <span class="preprocessor">        type * _q_f = (begin);                  \</span>
<a name="l01354"></a>01354 <span class="preprocessor">        for (; _q_f &lt; _q_e; ++_q_f) {           \</span>
<a name="l01355"></a>01355 <span class="preprocessor">            if (greater_equal(_q_f, (&amp;_q_n)))   \</span>
<a name="l01356"></a>01356 <span class="preprocessor">                break;                          \</span>
<a name="l01357"></a>01357 <span class="preprocessor">        }                                       \</span>
<a name="l01358"></a>01358 <span class="preprocessor">        dlseq_insert(type, head, _q_f, _q_n);   \</span>
<a name="l01359"></a>01359 <span class="preprocessor">    } while (0)</span>
<a name="l01360"></a>01360 <span class="preprocessor"></span>
<a name="l01373"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga0e70efb40f7d7cc678af7150990a2abb">01373</a> <span class="preprocessor">#define dlseq_is_sorted(type, begin, end, greater_equal, res) \</span>
<a name="l01374"></a>01374 <span class="preprocessor">    do {type * _q_e = (end);                                \</span>
<a name="l01375"></a>01375 <span class="preprocessor">        type * _q_i = (begin);                              \</span>
<a name="l01376"></a>01376 <span class="preprocessor">        for ((res) = 1; _q_i + 1 &lt; _q_e; ++_q_i) {          \</span>
<a name="l01377"></a>01377 <span class="preprocessor">            if (!(greater_equal((_q_i + 1), _q_i))) {       \</span>
<a name="l01378"></a>01378 <span class="preprocessor">                (res) = 0; break;                           \</span>
<a name="l01379"></a>01379 <span class="preprocessor">            }                                               \</span>
<a name="l01380"></a>01380 <span class="preprocessor">        }                                                   \</span>
<a name="l01381"></a>01381 <span class="preprocessor">    } while (0)</span>
<a name="l01382"></a>01382 <span class="preprocessor"></span>
<a name="l01392"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga2277c5ed79931683f4e900a5b0a6db47">01392</a> <span class="preprocessor">#define dlseq_bubble_sort(type, begin, end, greater) do {   \</span>
<a name="l01393"></a>01393 <span class="preprocessor">        int _q_pc = 1;                                      \</span>
<a name="l01394"></a>01394 <span class="preprocessor">        type * _q_l = (end) - 1;                            \</span>
<a name="l01395"></a>01395 <span class="preprocessor">        type * _q_i = (begin);                              \</span>
<a name="l01396"></a>01396 <span class="preprocessor">        for (; _q_pc &amp;&amp; _q_i &lt; _q_l; ++_q_i) {              \</span>
<a name="l01397"></a>01397 <span class="preprocessor">            type * _q_j = _q_l - 1;                         \</span>
<a name="l01398"></a>01398 <span class="preprocessor">            for (_q_pc = 0; _q_j &gt;= _q_i; --_q_j) {         \</span>
<a name="l01399"></a>01399 <span class="preprocessor">                type * _q_k = _q_j + 1;                     \</span>
<a name="l01400"></a>01400 <span class="preprocessor">                if (greater(_q_j, _q_k)) {                  \</span>
<a name="l01401"></a>01401 <span class="preprocessor">                    __dlseq_iter_swap(type, _q_j, _q_k);    \</span>
<a name="l01402"></a>01402 <span class="preprocessor">                    _q_pc = 1;                              \</span>
<a name="l01403"></a>01403 <span class="preprocessor">                }                                           \</span>
<a name="l01404"></a>01404 <span class="preprocessor">            }                                               \</span>
<a name="l01405"></a>01405 <span class="preprocessor">        }                                                   \</span>
<a name="l01406"></a>01406 <span class="preprocessor">    } while (0)</span>
<a name="l01407"></a>01407 <span class="preprocessor"></span>
<a name="l01417"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gab39a605aa355fd3dff3e38cc5b02fc9e">01417</a> <span class="preprocessor">#define dlseq_oddeven_sort(type, begin, end, greater) do {  \</span>
<a name="l01418"></a>01418 <span class="preprocessor">        int _q_pc = 1;                                      \</span>
<a name="l01419"></a>01419 <span class="preprocessor">        type * _q_l = (end) - 1;                            \</span>
<a name="l01420"></a>01420 <span class="preprocessor">        type * _q_f = (begin);                              \</span>
<a name="l01421"></a>01421 <span class="preprocessor">        while (_q_pc) {                                     \</span>
<a name="l01422"></a>01422 <span class="preprocessor">            int _q_w; _q_pc = 0;                            \</span>
<a name="l01423"></a>01423 <span class="preprocessor">            for (_q_w = 0; _q_w &lt; 2; ++_q_w)                \</span>
<a name="l01424"></a>01424 <span class="preprocessor">                __dlseq_oddeven_scan(_q_w, type, greater);  \</span>
<a name="l01425"></a>01425 <span class="preprocessor">        }                                                   \</span>
<a name="l01426"></a>01426 <span class="preprocessor">    } while (0)</span>
<a name="l01427"></a>01427 <span class="preprocessor"></span>
<a name="l01428"></a>01428 <span class="preprocessor">#define __dlseq_oddeven_scan(start, type, greater) do { \</span>
<a name="l01429"></a>01429 <span class="preprocessor">        type * _q_i = _q_f + start;                     \</span>
<a name="l01430"></a>01430 <span class="preprocessor">        while (_q_i &lt; _q_l) {                           \</span>
<a name="l01431"></a>01431 <span class="preprocessor">            type * _q_j = _q_i + 1;                     \</span>
<a name="l01432"></a>01432 <span class="preprocessor">            if (greater(_q_i, _q_j)) {                  \</span>
<a name="l01433"></a>01433 <span class="preprocessor">                __dlseq_iter_swap(type, _q_i, _q_j);    \</span>
<a name="l01434"></a>01434 <span class="preprocessor">                _q_pc = 1;                              \</span>
<a name="l01435"></a>01435 <span class="preprocessor">            }                                           \</span>
<a name="l01436"></a>01436 <span class="preprocessor">            _q_i += 2;                                  \</span>
<a name="l01437"></a>01437 <span class="preprocessor">        }                                               \</span>
<a name="l01438"></a>01438 <span class="preprocessor">    } while (0)</span>
<a name="l01439"></a>01439 <span class="preprocessor"></span>
<a name="l01449"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gabddc64a8dc69455900d3e1b359f4df46">01449</a> <span class="preprocessor">#define dlseq_cocktail_sort(type, begin, end, greater) do { \</span>
<a name="l01450"></a>01450 <span class="preprocessor">        int _q_pc;                                          \</span>
<a name="l01451"></a>01451 <span class="preprocessor">        type * _q_l = (end) - 1;                            \</span>
<a name="l01452"></a>01452 <span class="preprocessor">        type * _q_f = (begin);                              \</span>
<a name="l01453"></a>01453 <span class="preprocessor">        do {                                                \</span>
<a name="l01454"></a>01454 <span class="preprocessor">            type * _q_i = _q_f;                             \</span>
<a name="l01455"></a>01455 <span class="preprocessor">            for (_q_pc = 0; _q_i &lt; _q_l; ++_q_i) {          \</span>
<a name="l01456"></a>01456 <span class="preprocessor">                type * _q_j = _q_i + 1;                     \</span>
<a name="l01457"></a>01457 <span class="preprocessor">                if (greater(_q_i, _q_j)) {                  \</span>
<a name="l01458"></a>01458 <span class="preprocessor">                    __dlseq_iter_swap(type, _q_i, _q_j);    \</span>
<a name="l01459"></a>01459 <span class="preprocessor">                    _q_pc = 1;                              \</span>
<a name="l01460"></a>01460 <span class="preprocessor">                }                                           \</span>
<a name="l01461"></a>01461 <span class="preprocessor">            }                                               \</span>
<a name="l01462"></a>01462 <span class="preprocessor">            for (_q_i = --_q_l; _q_i &gt; _q_f; --_q_i) {      \</span>
<a name="l01463"></a>01463 <span class="preprocessor">                type * _q_j = _q_i - 1;                     \</span>
<a name="l01464"></a>01464 <span class="preprocessor">                if (greater(_q_j, _q_i)) {                  \</span>
<a name="l01465"></a>01465 <span class="preprocessor">                    __dlseq_iter_swap(type, _q_i, _q_j);    \</span>
<a name="l01466"></a>01466 <span class="preprocessor">                    _q_pc = 1;                              \</span>
<a name="l01467"></a>01467 <span class="preprocessor">                }                                           \</span>
<a name="l01468"></a>01468 <span class="preprocessor">            }                                               \</span>
<a name="l01469"></a>01469 <span class="preprocessor">            ++_q_f;                                         \</span>
<a name="l01470"></a>01470 <span class="preprocessor">        } while (_q_pc);                                    \</span>
<a name="l01471"></a>01471 <span class="preprocessor">    } while (0)</span>
<a name="l01472"></a>01472 <span class="preprocessor"></span>
<a name="l01482"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gae89fb9dc0c9a16ec88160cf6d5b7584a">01482</a> <span class="preprocessor">#define dlseq_comb_sort(type, begin, end, greater) do {         \</span>
<a name="l01483"></a>01483 <span class="preprocessor">        int _q_swap = 1;                                        \</span>
<a name="l01484"></a>01484 <span class="preprocessor">        type * _q_e = (end);                                    \</span>
<a name="l01485"></a>01485 <span class="preprocessor">        type * _q_f = (begin);                                  \</span>
<a name="l01486"></a>01486 <span class="preprocessor">        size_t _q_gap = _q_e - _q_f;                            \</span>
<a name="l01487"></a>01487 <span class="preprocessor">        while (_q_gap &gt; 1 || _q_swap) {                         \</span>
<a name="l01488"></a>01488 <span class="preprocessor">            type * _q_i, * _q_j;                                \</span>
<a name="l01489"></a>01489 <span class="preprocessor">            if (_q_gap &gt; 1)                                     \</span>
<a name="l01490"></a>01490 <span class="preprocessor">                _q_gap = (size_t)(((double)_q_gap)             \</span>
<a name="l01491"></a>01491 <span class="preprocessor">                      / 1.247330950103979);                     \</span>
<a name="l01492"></a>01492 <span class="preprocessor">            _q_i = _q_f;                                        \</span>
<a name="l01493"></a>01493 <span class="preprocessor">            _q_j = _q_f + _q_gap;                               \</span>
<a name="l01494"></a>01494 <span class="preprocessor">            for (_q_swap = 0; _q_j &lt; _q_e; ++_q_i, ++_q_j) {    \</span>
<a name="l01495"></a>01495 <span class="preprocessor">                if (greater(_q_i, _q_j)) {                      \</span>
<a name="l01496"></a>01496 <span class="preprocessor">                    __dlseq_iter_swap(type, _q_i, _q_j);        \</span>
<a name="l01497"></a>01497 <span class="preprocessor">                    _q_swap = 1;                                \</span>
<a name="l01498"></a>01498 <span class="preprocessor">                }                                               \</span>
<a name="l01499"></a>01499 <span class="preprocessor">            }                                                   \</span>
<a name="l01500"></a>01500 <span class="preprocessor">        }                                                       \</span>
<a name="l01501"></a>01501 <span class="preprocessor">    } while (0)</span>
<a name="l01502"></a>01502 <span class="preprocessor"></span>
<a name="l01512"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gab0b9b9efee02a2040aeef78b2a4f8b00">01512</a> <span class="preprocessor">#define dlseq_select_sort(type, begin, end, greater)    \</span>
<a name="l01513"></a>01513 <span class="preprocessor">    do {type * _q_e = (end);                            \</span>
<a name="l01514"></a>01514 <span class="preprocessor">        type * _q_i = (begin);                          \</span>
<a name="l01515"></a>01515 <span class="preprocessor">        for (; _q_i + 1 &lt; _q_e; ++_q_i) {               \</span>
<a name="l01516"></a>01516 <span class="preprocessor">            type * _q_m = _q_i;                         \</span>
<a name="l01517"></a>01517 <span class="preprocessor">            type * _q_j = _q_i + 1;                     \</span>
<a name="l01518"></a>01518 <span class="preprocessor">            for (; _q_j &lt; _q_e; ++_q_j) {               \</span>
<a name="l01519"></a>01519 <span class="preprocessor">                if (greater(_q_m, _q_j))                \</span>
<a name="l01520"></a>01520 <span class="preprocessor">                    _q_m = _q_j;                        \</span>
<a name="l01521"></a>01521 <span class="preprocessor">            }                                           \</span>
<a name="l01522"></a>01522 <span class="preprocessor">            if (_q_i != _q_m)                           \</span>
<a name="l01523"></a>01523 <span class="preprocessor">                __dlseq_iter_swap(type, _q_m, _q_i);    \</span>
<a name="l01524"></a>01524 <span class="preprocessor">        }                                               \</span>
<a name="l01525"></a>01525 <span class="preprocessor">    } while (0)</span>
<a name="l01526"></a>01526 <span class="preprocessor"></span>
<a name="l01536"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gade71f93f6b1deea1b17f5b15ef2da6e0">01536</a> <span class="preprocessor">#define dlseq_insert_sort(type, begin, end, greater) do {   \</span>
<a name="l01537"></a>01537 <span class="preprocessor">        type * _q_l = (end) - 1;                            \</span>
<a name="l01538"></a>01538 <span class="preprocessor">        type * _q_f = (begin);                              \</span>
<a name="l01539"></a>01539 <span class="preprocessor">        type * _q_i = _q_l - 1;                             \</span>
<a name="l01540"></a>01540 <span class="preprocessor">        for (; _q_i &gt;= _q_f; --_q_i) {                      \</span>
<a name="l01541"></a>01541 <span class="preprocessor">            type * _q_j = _q_l;                             \</span>
<a name="l01542"></a>01542 <span class="preprocessor">            for (; _q_j &gt; _q_i; --_q_j) {                   \</span>
<a name="l01543"></a>01543 <span class="preprocessor">                if (greater(_q_i, _q_j)) {                  \</span>
<a name="l01544"></a>01544 <span class="preprocessor">                    type _q_t = *_q_i;                      \</span>
<a name="l01545"></a>01545 <span class="preprocessor">                    memcpy(_q_i, _q_i + 1, sizeof(type) *   \</span>
<a name="l01546"></a>01546 <span class="preprocessor">                        (_q_j - _q_i));                     \</span>
<a name="l01547"></a>01547 <span class="preprocessor">                    *_q_j = _q_t;                           \</span>
<a name="l01548"></a>01548 <span class="preprocessor">                    break;                                  \</span>
<a name="l01549"></a>01549 <span class="preprocessor">                }                                           \</span>
<a name="l01550"></a>01550 <span class="preprocessor">            }                                               \</span>
<a name="l01551"></a>01551 <span class="preprocessor">        }                                                   \</span>
<a name="l01552"></a>01552 <span class="preprocessor">    } while (0)</span>
<a name="l01553"></a>01553 <span class="preprocessor"></span>
<a name="l01563"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gae061eca6e3a36bc7fb8b3e19cc3c2c0a">01563</a> <span class="preprocessor">#define dlseq_shell_sort(type, begin, end, greater) \</span>
<a name="l01564"></a>01564 <span class="preprocessor">    do {type * _q_e = (end);                        \</span>
<a name="l01565"></a>01565 <span class="preprocessor">        type * _q_f = (begin);                      \</span>
<a name="l01566"></a>01566 <span class="preprocessor">        size_t _q_gap = (_q_e - _q_f) &gt;&gt; 1;         \</span>
<a name="l01567"></a>01567 <span class="preprocessor">        for (; _q_gap; _q_gap &gt;&gt;= 1) {              \</span>
<a name="l01568"></a>01568 <span class="preprocessor">            type * _q_i = _q_f + _q_gap;            \</span>
<a name="l01569"></a>01569 <span class="preprocessor">            for (; _q_i &lt; _q_e; ++_q_i) {           \</span>
<a name="l01570"></a>01570 <span class="preprocessor">                type _q_t = *_q_i;                  \</span>
<a name="l01571"></a>01571 <span class="preprocessor">                type * _q_j = _q_i - _q_gap;        \</span>
<a name="l01572"></a>01572 <span class="preprocessor">                while (_q_j &gt;= _q_f &amp;&amp;              \</span>
<a name="l01573"></a>01573 <span class="preprocessor">                    (greater(_q_j, (&amp;_q_t)))) { \</span>
<a name="l01574"></a>01574 <span class="preprocessor">                    _q_j[_q_gap] = *_q_j;           \</span>
<a name="l01575"></a>01575 <span class="preprocessor">                    _q_j -= _q_gap;                 \</span>
<a name="l01576"></a>01576 <span class="preprocessor">                }                                   \</span>
<a name="l01577"></a>01577 <span class="preprocessor">                _q_j[_q_gap] = _q_t;                \</span>
<a name="l01578"></a>01578 <span class="preprocessor">            }                                       \</span>
<a name="l01579"></a>01579 <span class="preprocessor">        }                                           \</span>
<a name="l01580"></a>01580 <span class="preprocessor">    } while (0)</span>
<a name="l01581"></a>01581 <span class="preprocessor"></span>
<a name="l01582"></a>01582 <span class="comment">/* 计数排序和鸽巢排序(仅限于有限整数序列，需事先将hole清零) */</span>
<a name="l01583"></a>01583 <span class="preprocessor">#ifndef COUNTING_SIZE</span>
<a name="l01584"></a>01584 <span class="preprocessor"></span>
<a name="l01593"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga0e81257e6808089aea04c746c3b14b0b">01593</a> <span class="preprocessor">#define COUNTING_SIZE(_min, _max) ((_max) - (_min) + 1)</span>
<a name="l01594"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gabe56db9f8a1c3e4e29a31b7597b9b59e">01594</a> <span class="preprocessor"></span><span class="preprocessor">#define PIGEONHOLE_SIZE(_max) ((_max) + 1)</span>
<a name="l01595"></a>01595 <span class="preprocessor"></span><span class="preprocessor">#endif  </span><span class="comment">/* #ifndef COUNTING_SIZE */</span>
<a name="l01596"></a>01596 
<a name="l01618"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#ga0b0c8c04814080521e5951cc3cb293b7">01618</a> <span class="preprocessor">#define dlseq_counting_sort(type, begin, end, hole, _min, _max) \</span>
<a name="l01619"></a>01619 <span class="preprocessor">    do {type * _q_hole = (type *)(hole);                \</span>
<a name="l01620"></a>01620 <span class="preprocessor">        type * _q_e = (end);                            \</span>
<a name="l01621"></a>01621 <span class="preprocessor">        type * _q_f = (begin);                          \</span>
<a name="l01622"></a>01622 <span class="preprocessor">        type _q_min = (_min);                           \</span>
<a name="l01623"></a>01623 <span class="preprocessor">        type _q_cnt = (_max) - _q_min + 1;              \</span>
<a name="l01624"></a>01624 <span class="preprocessor">        type _q_i = 0;                                  \</span>
<a name="l01625"></a>01625 <span class="preprocessor">        memset(_q_hole, 0, sizeof(type) * _q_cnt);      \</span>
<a name="l01626"></a>01626 <span class="preprocessor">        while (_q_e &gt; _q_f)                             \</span>
<a name="l01627"></a>01627 <span class="preprocessor">            ++_q_hole[*(--_q_e) - _q_min];              \</span>
<a name="l01628"></a>01628 <span class="preprocessor">        for (; _q_i &lt; _q_cnt; ++_q_i) {                 \</span>
<a name="l01629"></a>01629 <span class="preprocessor">            size_t _q_c = _q_hole[_q_i];                \</span>
<a name="l01630"></a>01630 <span class="preprocessor">            while (_q_c--)                              \</span>
<a name="l01631"></a>01631 <span class="preprocessor">                *_q_f++ = _q_i;                         \</span>
<a name="l01632"></a>01632 <span class="preprocessor">        }                                               \</span>
<a name="l01633"></a>01633 <span class="preprocessor">    } while (0)</span>
<a name="l01634"></a>01634 <span class="preprocessor"></span>
<a name="l01655"></a><a class="code" href="group___xE5_x8F_x8C_xE7_xAB_xAF_xE7_xBA_xBF_xE5_xBD_xA2_xE5_xBA_x8F_xE8_xA1_xA8.html#gad3c68c03522faaa7f7be96cd94aaf62a">01655</a> <span class="preprocessor">#define dlseq_pigeonhole_sort(type, begin, end, hole, _max) \</span>
<a name="l01656"></a>01656 <span class="preprocessor">    dlseq_counting_sort(type, begin, end, hole, 0, _max)</span>
<a name="l01657"></a>01657 <span class="preprocessor"></span>
<a name="l01660"></a>01660 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l01661"></a>01661 <span class="preprocessor"></span>}
<a name="l01662"></a>01662 <span class="preprocessor">#endif </span><span class="comment">/* #ifdef __cplusplus */</span>
<a name="l01663"></a>01663 
<a name="l01664"></a>01664 <span class="preprocessor">#endif </span><span class="comment">/* #ifndef __NV_DLSEQ__ */</span>
<a name="l01665"></a>01665 
</pre></div></div>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>全部</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>数据结构</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>文件</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>函数</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>变量</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>类型定义</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>宏定义</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address class="footer"><small>Generated at 2015年七月16日 星期四 12:00:37 for Navo Portable Library by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address>
</body>
</html>
